<!doctype html>
<html lang="ar">
<head>
<meta charset="utf-8">
<title>تفاصيل الالتزام</title>

<!------------------------------ajax---------------------------->
<!-- <script type="text/javascript"  src="http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.js"></script> 
    <script type="text/javascript"  src="http://malsup.github.com/jquery.form.js"></script> -->
	
<!---------------------for autocomplete--------------->
	<script type="text/javascript" src="<?php echo base_url('assets/js/jquery-1.11.0.min.js');?>" ></script>
	<script type="text/javascript" src="<?php echo base_url('assets/js/jquery-ui-1.10.4/js/jquery-ui-1.10.4.min.js');?>" ></script>
	<link href="<?php echo base_url("assets/css/jquery-ui.css")?>" rel="stylesheet" type="text/css" />
<!---------------------for form css ----------------------->
	<link href="<?php echo base_url("assets/css/pure.css")?>" rel="stylesheet" type="text/css" />
<!---------------------for form validation ----------------------->
<script type="text/javascript" src="<?php echo base_url('assets/js/jquery.validate.js');?>" ></script>
<!---------------------for form mask input ----------------------->
<script type="text/javascript" src="<?php echo base_url('assets/js/jquery.mask.min.js');?>" ></script>


</head>
<body>
<?php
include_once('header.php');
$result=$engagement;  // one fournisseur


// ----- populate $liste_des_fournisseurs array for autocomplete ----- //

// ----- populate $liste_des_activites array for autocomplete ----- //
if($engagement[0]->nature==2 and !$engagement[0]->id_rapport_transfert_fk){
	$montant=$engagement[0]->montant_engagement;
}
$montant_milier=number_format($montant, 2, ',', ' ');
?>


<form id="bc_form" class="pure-form pure-form-stacked" method="POST" action="<?php echo base_url('bc_ctr/modifier_prod').'/'.$engagement[0]->id_engagement;?>">
    
        <legend>الرقم: <?php echo('<strong>'.$engagement[0]->numero.'</strong>');?></legend>

        <div class="pure-g">
            <div class="pure-u-1 pure-u-md-1-3" style="width: 25%">
                <label for="fournisseur">المادة </label>
				<label><?php echo($engagement[0]->nom);?></label>
            </div>

            <div class="pure-u-1 pure-u-md-1-3 " style="width: 25%">
                <label for="article">التاريخ </label>
                <label><?php echo($engagement[0]->date);?></label>
            </div>
			
			 <div class="pure-u-1 pure-u-md-1-3 " style="width: 25%">
                <label for="article">المبلغ </label>
                <label style="display: inline-block" class="ltr"><?php echo($montant_milier);?></label>
            </div>
			
			 <div class="pure-u-1 pure-u-md-1-3 " style="width: 25%">
                <label for="article">الطبيعة </label>
                <label style="display: inline-block" class="ltr"><?php echo($engagement[0]->nature);?></label>
            </div>

 <div class="pure-u-1 pure-u-md-1-3 " style="width: 30%">          
<?php		
echo ('
<a href="'. base_url("/engagement_crt/imprimer").'/'.$engagement[0]->id_engagement.'" class="pure-button pure-button-primary">طباعة</a>
 <a href="'. base_url("/engagement_crt/").'" class="pure-button pure-button-primary">خروج</a>
		
');			
?>	
</div>	
</form>
			
<?php
if($result[0]->nature==2){
	
	
}else{
	
if($bcs){ // test si il ya des bc dans le engagement avant afficher
echo(' 
<div>
 <form id="bc_form"  method="POST" action="">
			<div class="pure-u-1 pure-u-md-1-3 " style="width: 50%">
                <label for="numero" style="font-size:120%"> وصولات الطلب الخاصة بهذا الالتزام</label>
				
				</form>
				</div>
');
foreach($bcs as $data) 
{
	
  $rmq=0;
  $goupe=$this->session->userdata('user_group'); //access it


if($goupe=="admin"){ // si il est administrateur on affiche des bottons
 echo '
 <form id="bc_form"  method="POST" action="'.base_url('bc_ctr/modifier_prod').'/'.$data->id_bc.'">
			<div class="pure-u-1 pure-u-md-1-3 " style="width: 20%">
                <label for="numero"> الرقم </label>
				<label>'.$data->numero.'</label>
                
            </div>
			<div class="pure-u-1 pure-u-md-1-3 " " style="width: 20%">
                <label for="numero">المورد</label>
				<label>'.$data->nom.'</label>
                
            </div>
			<div class="pure-u-1 pure-u-md-1-3 " " style="width: 20%">
                <label for="numero"> التاريخ </label>
				<label>'.$data->date.'</lablel>
                
            </div>
			
			<div  class="pure-u-1 pure-u-md-1-3" " style="width: 20%">
	 
	   <a href="'.base_url("/bc_ctr/verifie_seuill_fournisseur/$data->id_fournisseur_fk/$data->id_bc/").'" class="pure-button pure-button-primary">تفاصيل</a>
			 </div>
			 </form>
			';
			
	}
	
}

}else{// pas de bcs dans ce engagement
echo('<div id="les prod" style="width: 90%; text-align: center; letter-spacing:0.5px;">
			<br>
			  <label style="font-size:150% ">	لا يوجد وصولات الطلب الخاصة بهذا الالتزام </label>
				
			<br>
			</div>');
}

if($conventions){ // test si il ya des conventions dans le engagement avant afficher
echo('<div>
 <form id="bc_form"  method="POST" action="">
			<div class="pure-u-1 pure-u-md-1-3 " style="width: 50%">
                <label for="numero" style="font-size:150%"> الاتفاقيات الخاصة بهذا الالتزام</label>
				
				</form>
				</div>');
foreach($conventions as $data) 
{
  $regularise=$data->is_regularise;
  $rmq=0;
  $goupe=$this->session->userdata('user_group'); //access it


if($goupe=="admin"){ // si il est administrateur on affiche des bottons
 echo '
 <form id="bc_form"  method="POST" action="'.base_url('bc_ctr/modifier_prod').'/'.$data->id_convetion.'">
			<div class="pure-u-1 pure-u-md-1-3 " style="width: 20%">
                <label for="numero"> الرقم </label>
				<label>'.$data->numero.'</label>
                
            </div>
			<div class="pure-u-1 pure-u-md-1-3 " " style="width: 20%">
                <label for="numero">المورد</label>
				<label>'.$data->nom.'</label>
                
            </div>
			<div class="pure-u-1 pure-u-md-1-3 " " style="width: 20%">
                <label for="numero"> التاريخ </label>
				<label>'.$data->date.'</label>
                
            </div>
			
			<div  class="pure-u-1 pure-u-md-1-3" " style="width: 20%">
	 
	   <a href="'.base_url("/convention_crt/get_detaille_convention/$data->id_convetion/$rmq/$regularise").'" class="pure-button pure-button-primary">تفاصيل</a>
	  	 </div>
			 </form>
			';
			
	}
	
}

}else{
	echo('<div id="les prod" style="width: 90%; text-align: center; letter-spacing:0.5px;">
			<br>
			  <label style="font-size:150% ">	لا يوجد اتفاقيات خاصة بهذا الالتزام </label>
				
			<br>
			</div>');
}
}
?>
     </div>
		</div>
   
  <?php
  $msg=0;
  $chemin=$this->uri->uri_string;
  $goupe=$this->session->userdata('user_group'); //access it

?>
		
			

</body>

<script>
$(document).ready(function() {

var liste_fourniss = <?php echo json_encode($liste_des_fournisseurs); ?>;
var liste_prod = <?php echo json_encode($liste_des_produit); ?>;
$( "#nom" ).autocomplete({source: liste_fourniss});
for(j=0;j<7;j++)	{
$( "#dessignation".concat(j) ).autocomplete({source: liste_prod});
}


});

//---



</script>
<script> 
 $(document).ready( function() {
	$('#send').click(function(){
		//    $("#bc_form").submit(function () {
	            $.post("<?php echo base_url("/bc_ctr/test/$i");?>",$("#bc_form").serialize(),function(texte){
	                        $("#ajout").append(texte);
							
					
	            });
				
				
	            return false; // ne change pas de page
				
                  
	    });
				
	});
	

</script>
</html>